Skip to content

Tighten canonical-repo match in queryTargetsDependingOnModules#338

Merged
tinder-maxwellelliott merged 1 commit into
Tinder:masterfrom
rdark:fix/query-modules-canonical-match
May 19, 2026
Merged

Tighten canonical-repo match in queryTargetsDependingOnModules#338
tinder-maxwellelliott merged 1 commit into
Tinder:masterfrom
rdark:fix/query-modules-canonical-match

Conversation

@rdark
Copy link
Copy Markdown
Contributor

@rdark rdark commented Apr 28, 2026

Partial fix for #335.

Layered on top #353 (parse-asymmetry guard), #354 (base-canonical-repo predicate). Hardens several edge cases in the surrounding code:

  • Set<Module> restructuring. detectChangedModules now returns typed Modules instead of module-key strings, wiring module.name up to the canonical-match predicate.

  • Real hash diff in the rdeps union. Fix computeSimpleImpactedTargets(emptyMap(), allTargets) returning allTargets.keys and silently unioning every target back into the rdeps result. Wire up from so the union uses the real hash diff.

  • reject empty module.name at the parser. The unnamed-root MODULE.bazel case (where bazel mod graph --output=json emits name="") would otherwise reach canonicalRepoIsBaseForModule and over-match every canonical.

  • Shape-aware rdeps-failure fallback. The unconditional !startsWith("@@") filter left only //external:* bridges on bzlmod-only workspaces, which excludeExternalTargets default (from Fix #326: filter //external:* labels from impacted-targets output on bzlmod #334) then strips to empty. Instead emit the buildable subset (//... minus //external:*) when non-empty, otherwise every hashed label. Extracted as isBuildableWorkspaceTarget.

  • Log-noise downgrade. Per-module "no external repository found" goes from WARN to INFO, plus a single aggregate INFO at the end.

Tests in CalculateImpactedTargetsInteractorModuleQueryTest: substring no-over-match, sentinel for execute, both branches of the shape-aware fallback, canonical dedup on add+remove version bumps, and the excludeExternalTargets interaction with the catch-fallback. New ModuleGraphParserTest case for empty-name rejection.

Changes vs the previous PR draft:

  • Drops the "two-tier predicate / Tier A / Tier B" framing from previous; canonicalRepoIsBaseForModule from Fix #326: filter //external:* labels from impacted-targets output on bzlmod #334 does this more concisely
  • Drops the long-form test enumeration in favour of a short paragraph that names the invariants covered, not individual test methods
  • Adds the new excludeExternalTargets interaction tests to the test summary.

@rdark rdark force-pushed the fix/query-modules-canonical-match branch 2 times, most recently from e031d63 to 1f737d4 Compare April 28, 2026 10:03
@tinder-maxwellelliott
Copy link
Copy Markdown
Collaborator

@rdark There is a conflict now. Thanks again for this

@rdark rdark force-pushed the fix/query-modules-canonical-match branch 2 times, most recently from 0d4922c to 9c3b424 Compare May 14, 2026 12:01
@rdark
Copy link
Copy Markdown
Contributor Author

rdark commented May 14, 2026

@tinder-maxwellelliott fixed up the conflicts and simplified this one a bit - thanks!

@tinder-maxwellelliott
Copy link
Copy Markdown
Collaborator

@rdark I think I addressed some of this from another issue, sorry for another conflict

@rdark
Copy link
Copy Markdown
Contributor Author

rdark commented May 18, 2026

No worries! Will take another look tomorrow

@tinder-maxwellelliott tinder-maxwellelliott self-assigned this May 18, 2026
Layered on top of Tinder#335 fixes (Tinder#353 parse-asymmetry guard, Tinder#354
base-canonical-repo predicate), this commit hardens several edge cases
in the surrounding code.

* Restructure detectChangedModules to return Set<Module> instead of
  module-key strings, threading module.name straight to the
  canonical-match predicate.

* Fix `computeSimpleImpactedTargets(emptyMap(), allTargets)` returning
  allTargets.keys, silently unioning every target back into the rdeps
  result. Thread `from` so the union uses the real hash diff.

* Reject empty module.name in ModuleGraphParser.extractModules. The
  unnamed-root MODULE.bazel case (where `bazel mod graph --output=json`
  emits name="") would otherwise reach canonicalRepoIsBaseForModule
  and over-match every canonical.

* Downgrade per-module "no external repository found" from WARN to
  INFO and emit a single aggregate at the end.

* Make the rdeps-failure fallback shape-aware for bzlmod-only
  workspaces. The unconditional !startsWith("@@") filter left only
  //external:* bridges, which the downstream excludeExternalTargets
  default (Tinder#334) then strips to empty. Replace with a shape-aware
  fallback: emit the buildable subset (//... minus //external:) when
  non-empty, otherwise every hashed label. Extracted as
  isBuildableWorkspaceTarget.

* New tests in CalculateImpactedTargetsInteractorModuleQueryTest cover
  substring no-over-match, sentinel for the execute path, both branches
  of the shape-aware fallback, canonical dedup on add+remove version
  bumps, and the excludeExternalTargets interaction with the
  catch-fallback. New parser test covers empty-name rejection.
@rdark rdark force-pushed the fix/query-modules-canonical-match branch from 9c3b424 to 00e83da Compare May 19, 2026 08:33
@rdark
Copy link
Copy Markdown
Contributor Author

rdark commented May 19, 2026

@tinder-maxwellelliott fixed up the remaining parts of this PR that still have some value post #334

Copy link
Copy Markdown
Collaborator

@tinder-maxwellelliott tinder-maxwellelliott left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you

@tinder-maxwellelliott tinder-maxwellelliott merged commit a493b9b into Tinder:master May 19, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants